//=======================================================================================
//= IPBlock.cpp
//=======================================================================================
#include "StdAfx.h"

//------------------------------------------------------
//- Variables
//------------------------------------------------------
IPBLOCK IPBlockInfo[255];
int IPBlockCount;

//------------------------------------------------------
//- Start
//------------------------------------------------------
void LoadIPBlock()
{
	//------------------------------------------------------
	FILE *fp;
	BOOL bRead = FALSE;
	DWORD dwArgv = 0;
	char sLineTxt[255] = {0};
	IPBlockCount = 1;
	//------------------------------------------------------
	fp = fopen(INI_BLOCKED_IP,"r");
	//------------------------------------------------------
	if(!fp)
	{
		Tools.MessageBoxShow("BlockedIPList.script not found!","File not found!");
		Exit;
	}
	//------------------------------------------------------
	rewind(fp);
	//------------------------------------------------------
	while(fgets(sLineTxt, 255, fp) != NULL)
	{
		//------------------------------------------------------
		if(sLineTxt[0] == '/')continue;
		if(sLineTxt[0] == ';')continue;
		//------------------------------------------------------
		char IP[16];
		//------------------------------------------------------
		sscanf(sLineTxt, "%s", &IP);
		//------------------------------------------------------
		sprintf(IPBlockInfo[IPBlockCount].IP,"%s",IP);
		//------------------------------------------------------
		Console.Write("[IPBlock] Blocked %s IP!",IP);
		//------------------------------------------------------
		IPBlockCount++;
		//------------------------------------------------------
	}
	//------------------------------------------------------
	rewind(fp);
	fclose(fp);
	//------------------------------------------------------
	Console.Write("[Antihack] %d Banned IP's loaded!",IPBlockCount-1);
}
